import { GeneralResponse, UserInfoType } from "@/apiTypes";
import { requestSync } from "./request-helper";

// const baseUrl = "https://tebu.otype.com/tebu-wx/c/base-framework-c";
const baseUrl = "http://172.17.12.107:8068";
// const baseUrl = "https://api-vipinterests.daishubobo.com";

const apiUrl = {
  // userInfo: baseUrl + "/api/user/getUserInfo", //获取用户信息
  loginSession: baseUrl + "/client/loginApi/wx/session", //获取授权
  loginPhone: baseUrl + "/client/loginApi/wx/phone", //获取电话
  userInfo: baseUrl + "/system/user/getInfo", //获取用户信息
  register: baseUrl + "/auth/register", //注册
  userList: baseUrl + "/api/user/list", //用户列表
  getToken: baseUrl + "/upload/getToken", //getToken
  addTask: baseUrl + "/system/task/add", // 新增任务
  editTask: baseUrl + "/system/task/edit", // 新增任务
  systemTask: baseUrl + "/system/task", // 查询任务
  meeting: baseUrl + "/meeting", // 新增会议/日程
  systemRoomList: baseUrl + "/api/room/list", // 获取会议室列表
  dictDataTypeList: baseUrl + "/system/dict/data/type", // 查询字段数据列表
  meetingSchedule: baseUrl + "/meeting/schedule", // 获取会议日程安排
  meetingChangeStatus: baseUrl + "/meeting/changeStatus", // 缺席/接收会议
  meetingList: baseUrl + "/meeting/list", // 会议/日程列表
  systemRoom: baseUrl + "/system/room", // 新增会议室
  meetingListReservation: baseUrl + "/meeting/listReservation", // 查看指定日期预约会议列表
  meetingListHistory: baseUrl + "/meeting/listHistory", // 历史会议列表
  systemtaskList: baseUrl + "/system/task/list", //
  taskCreatorsTaskList: baseUrl + "/system/task/getCreatorsTaskList", // 任务列表
  taskReceiveCount: baseUrl + "/system/taskReceive/getCount", // 任务概况统计
  taskRecipientList: baseUrl + "/system/task/getRecipientTaskList", // 我的任务列表
  taskReceiveEdit: baseUrl + "/system/taskReceive/edit", // 接收/完成任务
  taskDepartmentBoardList: baseUrl + "/system/task/getDepartmentBoardList", // 任务进展看板1
  taskTaskSummaryList: baseUrl + "/system/task/getTaskSummaryList", // 任务进展看板2
  taskEmergencyTaskBoard: baseUrl + "/system/task/getEmergencyTaskBoard", // 任务进展看板3
  taskAdmin: baseUrl + "/system/task/getTaskAdmin", // 是否是管理员
  taskTeamList: baseUrl + "/system/task/getTeamList", // 团队的任务看板总的
  taskPermissionList: baseUrl + "/api/taskPermission/list", // 任务管理员列表
  taskPermission: baseUrl + "/api/taskPermission", // 新增/编辑/删除任务管理员
  isPunchCard: baseUrl + "/attendance/attendanceRecord/checkFlag", // 获取是否能打卡
  attendanceAttendanceRecord: baseUrl + "/attendance/attendanceRecord", // 新增考勤记录
  // attendanceRecordList: baseUrl + "/attendance/attendanceRecord/list", // 查询考勤记录列表
  attendanceRecordQueryData: baseUrl + "/attendance/attendanceRecord/queryData", // 根据日期获取考勤记录详细信息
  attendanceRules: baseUrl + "/attendance/rules", // 打卡规则
  wifiList: baseUrl + "/attendance/wifi/list", // 查询wifi列表
  rulesList: baseUrl + "/attendance/rules/list", // 查询打卡规则列表
  attendanceRecordQueryDetailList: baseUrl + "/attendance/attendanceRecord/queryDetailList", // 打卡明细(日)
  attendanceRecordQueryStatistics: baseUrl + "/attendance/attendanceRecord/queryStatistics", // 根据日期范围获取考勤记录统计
  attendanceWifi: baseUrl + "/attendance/wifi", // 删除wifi
  checkDeviceList: baseUrl + "/attendance/checkDevice/list", // 查询成员打卡设备列表
  attendanceCheckDevice: baseUrl + "/attendance/checkDevice", // 查询成员打卡设备列表
};

/**
 * @author zzw
 * @date 2023-11-22 11:32:49
 * @desc 用户信息
 */
export const getUserInfo = async (): Promise<GeneralResponse<UserInfoType>> => {
  return requestSync({
    url: apiUrl.userInfo,
    method: "GET",
  });
};
export const getLoginSession = async (data: any) => {
  return requestSync({
    url: apiUrl.loginSession,
    method: "GET",
    data: data,
  });
};
export const getLoginPhone = async (data: any) => {
  return requestSync({
    url: apiUrl.loginPhone,
    method: "GET",
    data: data,
  });
};
export const getRegister = async (data: any) => {
  return requestSync({
    url: apiUrl.register,
    method: "POST",
    data: data,
  });
};

export const getUserList = async (data: any) => {
  return requestSync({
    url: apiUrl.userList,
    method: "GET",
    data: data,
  });
};
export const getTokens = async (data: any) => {
  return requestSync({
    url: apiUrl.getToken,
    method: "POST",
    data: data,
  });
};
export const addSystemTask = async (data: any) => {
  return requestSync({
    url: apiUrl.addTask,
    method: "POST",
    data: data,
  });
};
export const editSystemTask = async (data: any) => {
  return requestSync({
    url: apiUrl.editTask,
    method: "PUT",
    data: data,
  });
};
export const queryTask = async (id: any) => {
  return requestSync({
    url: apiUrl.systemTask + "/" + id,
    method: "GET",
  });
};
export const addMeeting = async data => {
  return requestSync({
    url: apiUrl.meeting,
    method: "POST",
    data: data,
  });
};
// 查询
export const queryMeeting = async id => {
  return requestSync({
    url: apiUrl.meeting + "/" + id,
    method: "GET",
  });
};
// 修改
export const editMeeting = async data => {
  return requestSync({
    url: apiUrl.meeting,
    method: "PUT",
    data: data,
  });
};
// 删除
export const deleteMeeting = async id => {
  return requestSync({
    url: apiUrl.meeting + "/" + id,
    method: "DELETE",
  });
};
export const getSystemRoomList = async () => {
  return requestSync({
    url: apiUrl.systemRoomList,
    method: "GET",
    // data: data,
  });
};
export const getDictDataTypeList = async (data: any) => {
  return requestSync({
    url: apiUrl.dictDataTypeList + "/" + data,
    method: "GET",
    // data: data,
  });
};
export const getMeetingSchedule = async (data: any) => {
  return requestSync({
    url: apiUrl.meetingSchedule,
    method: "GET",
    data: data,
  });
};
export const getMeetingChangeStatus = async (data: any) => {
  return requestSync({
    url: apiUrl.meetingChangeStatus,
    method: "GET",
    data: data,
  });
};
export const getMeetingList = async (data: any) => {
  return requestSync({
    url: apiUrl.meetingList,
    method: "GET",
    data: data,
  });
};
export const addSystemRoom = async (data: any) => {
  return requestSync({
    url: apiUrl.systemRoom,
    method: "POST",
    data: data,
  });
};
export const getMeetingListReservation = async (data: any) => {
  return requestSync({
    url: apiUrl.meetingListReservation,
    method: "GET",
    data: data,
  });
};
export const getMeetingListHistory = async (data: any) => {
  return requestSync({
    url: apiUrl.meetingListHistory,
    method: "GET",
    data: data,
  });
};
export const getSystemtaskList = async (data: any) => {
  return requestSync({
    url: apiUrl.systemtaskList,
    method: "GET",
    data: data,
  });
};
export const getTaskCreatorsTaskList = async (data: any) => {
  return requestSync({
    url: apiUrl.taskCreatorsTaskList,
    method: "GET",
    data: data,
  });
};
export const getTaskReceiveCount = async () => {
  return requestSync({
    url: apiUrl.taskReceiveCount,
    method: "GET",
  });
};
export const getRecipientTaskList = async (data: any) => {
  return requestSync({
    url: apiUrl.taskRecipientList,
    method: "GET",
    data: data,
  });
};
export const getTaskReceiveEdit = async (data: any) => {
  return requestSync({
    url: apiUrl.taskReceiveEdit,
    method: "PUT",
    data: data,
  });
};
export const getTaskDepartmentBoardList = async () => {
  return requestSync({
    url: apiUrl.taskDepartmentBoardList,
    method: "GET",
  });
};
export const getTaskTaskSummaryList = async () => {
  return requestSync({
    url: apiUrl.taskTaskSummaryList,
    method: "GET",
  });
};
export const getTaskEmergencyTaskBoard = async () => {
  return requestSync({
    url: apiUrl.taskEmergencyTaskBoard,
    method: "GET",
  });
};
export const getTaskAdmin = async (data: any) => {
  return requestSync({
    url: apiUrl.taskAdmin,
    method: "GET",
    data: data,
  });
};
export const getTaskTeamList = async (data: any) => {
  return requestSync({
    url: apiUrl.taskTeamList,
    method: "GET",
    data: data,
  });
};

export const getTaskPermissionList = async (data: any) => {
  return requestSync({
    url: apiUrl.taskPermissionList,
    method: "GET",
    data: data,
  });
};
export const delTaskPermission = async (id: any) => {
  return requestSync({
    url: apiUrl.taskPermission + "/" + id,
    method: "DELETE",
  });
};
export const addTaskPermission = async (data: any) => {
  return requestSync({
    url: apiUrl.taskPermission,
    method: "POST",
    data: data,
  });
};
// 打卡
export const postIsPunchCard = async (data: any) => {
  return requestSync({
    url: apiUrl.isPunchCard,
    method: "POST",
    data: data,
  });
};
export const addAttendanceRecord = async (data: any) => {
  return requestSync({
    url: apiUrl.attendanceAttendanceRecord,
    method: "POST",
    data: data,
  });
};
export const getAttendanceRecordQueryData = async (data: any) => {
  return requestSync({
    url: apiUrl.attendanceRecordQueryData,
    method: "GET",
    data: data,
  });
};
export const addAttendanceRules = async (data: any) => {
  return requestSync({
    url: apiUrl.attendanceRules,
    method: "POST",
    data: data,
  });
};
export const getWifiLists = async (data: any) => {
  return requestSync({
    url: apiUrl.wifiList,
    method: "GET",
    data: data,
  });
};
export const getRulesList = async (data: any) => {
  return requestSync({
    url: apiUrl.rulesList,
    method: "GET",
    data: data,
  });
};
export const getAttendanceRecordQueryDetailList = async (data: any) => {
  return requestSync({
    url: apiUrl.attendanceRecordQueryDetailList,
    method: "GET",
    data: data,
  });
}
export const getAttendanceRecordQueryStatistics = async (data: any) => {
  return requestSync({
    url: apiUrl.attendanceRecordQueryStatistics,
    method: "GET",
    data: data,
  });
}
export const deleteAttendanceWifi = async (data: any) => {
  return requestSync({
    url: apiUrl.attendanceWifi + '/' + data,
    method: "DELETE",
  });
}
export const addAttendanceWifi = async (data: any) => {
  return requestSync({
    url: apiUrl.attendanceWifi,
    method: "POST",
    data: data,
  });
}
export const getCheckDeviceList = async (data: any) => {
  return requestSync({
    url: apiUrl.checkDeviceList,
    method: "GET",
    data: data,
  });
}
export const deltattendanceCheckDevice = async (data: any) => {
  return requestSync({
    url: apiUrl.attendanceCheckDevice + '/' + data,
    method: "DELETE",
  });
}